#region

using System;
using System.ComponentModel.DataAnnotations.Schema;

#endregion

namespace CuongHanh.Models
{
    [Table("tbl_MyStyle")]
    public class MyStyle : BaseClassMultiCache
    {
        public override int KeyObject
        {
            get
            {
                return Id;
            }
        }

        public override int? KeyList
        {
            get
            {
                return ParentId;
            }
        }

        public string Name { get; set; }

        public string NameEn { get; set; }

        public string Code { get; set; }

        public int StyleTypeId { get; set; }

        public int? ParentId { get; set; }

        public string Image { get; set; }

        public string Description { get; set; }

        public string DescriptionEn { get; set; }

        [NotMapped]
        public string Description_e { get; set; }

        [NotMapped]
        public string DescriptionEn_e { get; set; }

        #region Function

        public MyStyle()
        {
        }

        public MyStyle(MyStyle model)
        {
            Code = model.Code;
            Name = model.Name;
            NameEn = model.NameEn;
            StyleTypeId = model.StyleTypeId;
            Description = model.Description;
            DescriptionEn = model.DescriptionEn;
            ParentId = model.ParentId;
            Image = model.Image;
            Inactive = false;
            LastModified = DateTime.Now;
        }

        public void UpdateInfo(MyStyle model)
        {
            Code = model.Code;
            Name = model.Name;
            NameEn = model.NameEn;
            StyleTypeId = model.StyleTypeId;
            //Description = model.Description;
            //DescriptionEn = model.DescriptionEn;
            ParentId = model.ParentId;
            if(!string.IsNullOrWhiteSpace(model.Image))
                Image = model.Image;
            Inactive = false;
            LastModified = DateTime.Now;
        }

        public MyStyle UpdateCache(MyStyle oldModel,
                MyStyle newModel)
        {
            oldModel.Code = newModel.Code;
            oldModel.Name = newModel.Name;
            oldModel.NameEn = newModel.NameEn;
            oldModel.StyleTypeId = newModel.StyleTypeId;
            oldModel.Description = newModel.Description;
            oldModel.DescriptionEn = newModel.DescriptionEn;
            oldModel.ParentId = newModel.ParentId;
            oldModel.Image = newModel.Image;
            oldModel.Inactive = false;
            oldModel.LastModified = DateTime.Now;
            return oldModel;
        }

        #endregion
    }
}
